package com.server.http.handler.impl;

import java.util.ArrayList;
import java.util.List;

import com.server.background.data.RankTableData;
import com.server.conditionenum.HttpReturnStatus;
import com.server.http.handler.HttpHandler;
import com.server.http.request.HttpRequestMessage;
import com.server.http.response.HttpResponseMessage;
import com.server.mine.net.HttpProtocol;
import com.server.tools.AppData;

/**
* @author	李小布
* @email	397554852@qq.com
* @version	创建时间：2018年9月29日 下午4:43:55
*/
public class GetAllRanklist extends HttpHandler{

	@Override
	public void handle(HttpRequestMessage request, HttpResponseMessage response) {
		int power = 0;
		int uid = 0;
		List<RankTableData> rankTableDatas = new ArrayList<RankTableData>();
		
		try {
			power = Integer.parseInt(request.getParameter("power"));
			uid = Integer.parseInt(request.getParameter("uid"));
			rankTableDatas = AppData.GetAllRanklist(uid,power);
		}catch (Exception e) {
			e.printStackTrace();
		}
		
		if(rankTableDatas.size() > 0) {
			SetReturnData(response,rankTableDatas,HttpProtocol.GETALLRANKLIST,HttpReturnStatus.Successed);
		}else {
			SetReturnData(response,null,HttpProtocol.GETALLRANKLIST,HttpReturnStatus.Failed);
		}
	}
}